<template>
	<view class="my-page">
		<u-navbar leftIconColor="#ffffff" :autoBack="true" :placeholder="true" bgColor="rgba(255,255,255,0.0)">
			<view slot="center" class="nav-title">
				我的团队
			</view>
		</u-navbar>
		<view class="head-box">
			<view class="head-top">
				<view class="head-left">
					<view class="head-text">
						团队总人数
					</view>
					<view class="head-num">
						{{info.team}}
					</view>
				</view>
			</view>
			<view class="member">
				<view class="member-left">
					<view class="left-text">
						有效成员人数
					</view>
					<view class="left-num">
						{{info.yx_team}}
					</view>
				</view>
				<view class="member-right">
					<view class="right-text">
						筛选有效成员
					</view>
					<view class="switch">
						<u-switch v-model="show" @change="change" activeColor="#FFD7A2"></u-switch>
					</view>
				</view>
			</view>
		</view>
		<view class="tabs">
			<view :class="current == index?'active-item': 'tabs-item'" class="tabs-item"
				v-for="(item,index) in tabsList" :key="index" @click="cutTab(index,item.type)">
				{{item.text}}
			</view>
		</view>
		<view v-if="teamlist.length > 0">
			<view class="item" v-for="(item,index) in teamlist" :key="index">
				<view class="item-top">
					<image :src="item.avatar" mode=""></image>
					<view class="item-right">
						<view class="name">
							{{item.user}}
						</view>
						<view class="tell">
							ID:{{item.id||'0'}}
						</view>
						<view class="tell">
							注册时间：{{item.create_time }}
						</view>
					</view>
				</view>
				<view class="item-bottom">
					<view class="person">
						<view class="per-title">个人资产</view>
						<view class="per-num" style="color: #FFD7A2;">{{item.reward_census|| 0}}</view>
					</view>
					<view class="person">
						<view class="per-title">邀请人数</view>
						<view class="per-num">{{item.team|| 0}}</view>
					</view>
					<view class="person">
						<view class="per-title">总收益 </view>
						<view class="per-num">{{item.team_shouyi || 0}}</view>
					</view>
				</view>
			</view>
			<u-loadmore :status="status" />
		</view>
		<u-empty v-else mode="car" icon="../../../static/home/none.png" text="暂无数据" marginTop="50">
		</u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				tabsList: [{
						text: '直推',
						type: 1
					},
					{
						text: '团队',
						type: 4
					},
					// {
					// 	text: '三级'
					// },
					// {
					// 	text: '四级'
					// }
				],
				status: 'loadmore',
				current: 0,
				info: {},
				teamlist: [],
				type: 1,
				page: 1
			}
		},
		onLoad() {
			this.teaminfo()
		},
		onReachBottom() {
			this.page++
			this.status = 'loading';
			this.teaminfo()
		},
		methods: {
			teaminfo() {
				let params = {
					page: this.page,
					type: this.type,
					status: this.show == false ? 0 : 1
				}
				this.$Request({
					method: 'POST',
					url: '/api/personal/team',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data
						if (res.data.list.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.teamlist = res.data.list
						} else {
							this.teamlist = [...this.teamlist, ...res.data.list]
						}

					}
				})

			},
			change(e) {
				this.page = 1
				this.teaminfo()
			},
			cutTab(index, type) {
				this.current = index
				this.page = 1
				this.type = type
				this.teaminfo()
			}
		}
	}
</script>
<style>
	page {
		background: #000000;
	}
</style>
<style lang="scss" scoped>
	.my-page {
		min-height: 100vh;
		position: relative;
		background-image: url('../../../static/login/login-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 593px;
		padding: 30rpx;

		.nav-title {
			color: #ffffff;
		}

		.head-box {
			border-radius: 30rpx;
			background: #1A1A1B;
			padding: 30rpx;
			position: relative;

			.head-top {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.head-left {
					color: #9C9CAD;

					.head-text {
						font-size: 24rpx;
					}

					.head-num {
						font-size: 59rpx;
						font-weight: bold;
						margin-top: 10rpx;
						color: #FFD7A2;
					}
				}

				.head-btn {
					color: #fff;
					font-size: 26rpx;
					padding: 10rpx 25rpx;
					background-color: rgba(255, 255, 255, .16);
					border-radius: 10rpx;
				}
			}

			.member {
				margin-top: 30rpx;
				border-radius: 20rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.member-left {
					color: #8F8F8F;

					.left-text {
						font-size: 28rpx;
					}

					.left-num {
						font-size: 36rpx;
						margin-top: 10rpx;
						color: #ffffff;
						font-weight: bold;
					}
				}

				.member-right {
					color: #8F8F8F;
					font-size: 28rpx;

					.right-text {
						margin-left: 20rpx;
						margin-bottom: 10rpx;
					}

					.switch {
						display: flex;
						align-items: center;
						justify-content: right;
					}
				}
			}
		}

		.tabs {
			display: flex;
			margin-top: 30rpx;
			padding: 10rpx;
			border: 1px solid #58585880;
			border-radius: 20rpx;

			.tabs-item {
				width: 50%;
				text-align: center;
				padding: 20rpx 0;
				font-size: 28rpx;
				font-weight: 500;
				color: #6c6c6c;
				background-color: rgba(0, 0, 0, 0);
			}

			.active-item {
				color: #000000;
				background-color: #fff;
				box-shadow: 0rpx 1rpx 50rpx 1rpx rgba(0, 0, 0, 0.08);
				border-radius: 10rpx;
			}
		}

		.item {
			padding: 30rpx;
			border-radius: 30rpx;
			background: #1A1A1B;
			margin-top: 40rpx;
			box-shadow: 0rpx 3rpx 32rpx 1rpx rgba(0, 0, 0, 0.08);

			.item-top {
				display: flex;
				align-items: center;

				image {
					width: 110rpx;
					height: 110rpx;
					border-radius: 50%;
				}

				.item-right {
					margin-left: 20rpx;

					.name {
						font-size: 32rpx;
						font-weight: bold;
						color: #ffffff;
					}

					.tell {
						color: #999999;
						font-size: 26rpx;
						margin-top: 5rpx;
					}
				}
			}

			.item-bottom {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.person {
					margin-top: 30rpx;
					font-size: 28rpx;
					text-align: center;
					padding: 0 20rpx;

					.per-title {
						font-size: 24rpx;
						color: #8F8F8F;
					}

					.per-num {
						margin-top: 10rpx;
						color: #ffffff;
						font-size: 30rpx;
						font-weight: 900;
					}
				}
			}
		}
	}
</style>